#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,L,V;
const int N=1e5+5,inf=2e9;
struct Car{
    int d,v,a;
}a[N];
int p[N];
int from[N],dp[N];
int ans1,ans2;
int q[N],l,r;
void solve(){
    scanf("%lld %lld %lld %lld",&n,&m,&L,&V);
    for(int i=1;i<=n;i++){
        scanf("%lld %lld %lld",&a[i].d,&a[i].v,&a[i].a);
    }
    for(int i=1;i<=m;i++){
        from[i]=0;
        dp[i]=inf;
        scanf("%lld",&p[i]);
    }
    ans1=0,ans2=inf;
    l=1,r=1;
    q[1]=0;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        int id=lower_bound(p+1,p+m+1,a[i].d)-p;
        if(id>m)continue;
        if(a[i].a==0){
            if(a[i].v<=V)continue;
            int id=lower_bound(p+1,p+m+1,a[i].d)-p;
            from[m]=max(from[m],id);
            ++ans1;
        }
        else if(a[i].a>0){
            int l=id,r=m,res=m+1;
            while(l<=r){
                int mid=l+r>>1;
                if(a[i].v*a[i].v+2*a[i].a*(p[mid]-a[i].d)>V*V)res=mid,r=mid-1;
                else l=mid+1;
            }
            if(res!=m+1){
                ++ans1;
                from[m]=max(from[m],res);
            }
        }
        else{
            int l=id,r=m,res=m+1;
            while(l<=r){
                int mid=l+r>>1;
                if(a[i].v*a[i].v+2*a[i].a*(p[mid]-a[i].d)>V*V)res=mid,l=mid+1;
                else r=mid-1;
            }
            if(res!=m+1){
                ++ans1;
                from[res]=max(from[res],id);
            }
        }
    }
    for(int i=1;i<=m;i++){
        dp[i]=dp[q[l]]+1;
        q[++r]=i;
        while(l<r&&q[l]<from[i])++l;
    }
    for(int i=l;i<=r;i++)ans2=min(ans2,dp[q[i]]);
    printf("%lld %lld\n",ans1,m-ans2);
    return;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%lld",&T);
    while(T--)solve();    
    return 0;
}